import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";

//配置中文环境
import { ConfigProvider } from "antd";
import zhCN from "antd/es/locale/zh_CN";

//全觉样式css
import './css/index.css'

//配置路由
import {
  HashRouter,
  Route,
  Switch,
  Redirect,
} from "react-router-dom";
import {commonRoutes} from './routers'



ReactDOM.render(
  <ConfigProvider locale={zhCN}>
    <HashRouter>
      <Switch>
        <Route path="/admin" render={(rootProps)=>{
          //登陆授权
          console.log('rootProps',rootProps);
          return <App {...rootProps}/>
        }}></Route>
      {
        commonRoutes.map((item,index)=>{
          return(
            <Route path={item.pathname} key={index} component={item.component}></Route>
          )
        })
      }
      <Redirect from="/" to="admin" exact></Redirect>
      <Redirect from="*" to="/404"></Redirect>
      </Switch>
    </HashRouter>
  </ConfigProvider>,
  document.getElementById("root")
);
